<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id='app'>
        <button v-text="message" class="btn btn-primary" @click="time" :disabled='flag'></button>
    </div>
</body>
<script>
    const vm = new Vue({
        el: '#app',
        data: {
            flag: false,
            message: '获取验证码',
            seconds: 60
        },
        methods: {
            time() {
                this.flag = true
                let timer = setInterval(() => {
                    this.seconds--
                    this.message = this.seconds + 's后重新发送'
                    if (!this.seconds) {
                        clearInterval(timer)
                        this.flag = false
                        this.seconds = 60
                        this.message = '获取验证码'
                    }
                }, 1000)
            }
        }
    })
</script>

</html>